package com.github.baichuan.application.scaffold.rest.jpa.organization;

import com.github.baichuan.application.scaffold.rest.domain.application.Application;
import com.github.baichuan.application.scaffold.rest.domain.organization.Tenant;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.Optional;

public interface TenantRepository extends JpaRepository<Tenant, String>, JpaSpecificationExecutor<Tenant> {

    @Query("select tenant from Tenant tenant where tenant.application=:application and name=:name")
    Optional<Tenant> find(@Param("application") Application application, @Param("name") String name);
}
